package com.yanqu.road.server.cmd.activity.turtle;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.TurtleProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.turtle.TurtleModule;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.turtle.TurtleMgr;
import com.yanqu.road.server.manger.activity.turtle.TurtleConfig;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

/**
 * @Author : Cxp
 * @Time : 2024-09-09
 * @Description : 乌龟对对碰-选择幸运色
 */

@Cmd(code = Protocol.S_TURTLE_CHOOSE_LUCKY_COLOR, desc = "选择幸运色")
public class TurtleChooseLuckyColorCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        TurtleProto.TurtleChooseLuckyColorReq req = TurtleProto.TurtleChooseLuckyColorReq.parseFrom(packet.getBytes());
        ret = player.getModule(TurtleModule.class).chooseLuckyColor(req.getActivityId(), req.getColor());
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            player.sendPacket(Protocol.U_TURTLE_CHOOSE_LUCKY_COLOR, TurtleProto.TurtleChooseLuckyColorResp.newBuilder().setRet(ret));
        }
    }
}
